#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>


/*
 * 4个LED轮流闪烁，同时蜂鸣器以一定周期发出声响
 */

#if 0
int led_timer(int dev_fd, int led_no, unsigned int time)
{ /*指定LED发亮一段时间之后熄灭它*/
    led_no %= 4;
    ioctl(dev_fd, LED_D09_SWT + led_no, LED_SWT_ON); /* 发亮*/
    sleep(time);
    ioctl(dev_fd, LED_D09_SWT + led_no, LED_SWT_OFF); /* 熄灭 */
}
 
int beep_timer(int dev_fd, unsigned int time)
{/* 开蜂鸣器一段时间之后关闭*/
    ioctl(dev_fd, BEEP_SWT, BEEP_SWT_ON); /* 发声*/
    sleep(time);
    ioctl(dev_fd, BEEP_SWT, BEEP_SWT_OFF);    /* 关闭 */
}
 
int main()
{
    int i = 0;
    int dev_fd;
        /* 打开gpio设备 */
    dev_fd = open(GPIO_DEVICE_FILENAME, O_RDWR | O_NONBLOCK);
    if ( dev_fd == -1 ) 
    {
        printf("Cann't open gpio device file\n");
        exit(1);
    }
 
    while(1)
    {
        i = (i + 1) % 4;
        led_timer(dev_fd, i, 1);
        beep_timer(dev_fd, 1);        
    }
    close(dev_fd);
    return 0;
}           
#endif

void main()
{

}
